import re

str01 = 'abcdefghijklmnop'
str02 = 'abcdefghabcsabcdefjklmnopqrstuvw'

max_str = str01 if len(str01) > len(str02) else str02
min_str = str01 if len(str01) < len(str02) else str02
list_re = list()
for i in min_str:
    if i in max_str:
        for res in re.finditer(i, max_str):
            temp = ''
            temp += i
            index_a = min_str.index(i)
            index_b = res.span()[0]
            while True:
                try:
                    if min_str[index_a + 1] == max_str[index_b + 1]:
                        temp += min_str[index_a + 1]
                        index_a += 1
                        index_b += 1
                    else:
                        break
                except IndexError:
                    break
            if temp not in list_re:
                list_re.append(temp)


res = list()
for n in range(len(list_re)):
    is_in = list()
    for m in range(len(list_re)):
        if n == m:
            continue
        else:
            if list_re[n] in list_re[m]:
                is_in.append(1)
            else:
                is_in.append(0)
    if 1 not in is_in:
        res.append(list_re[n])
    else:
        continue
res = max(list_re, key=len)
print(res)
